// STFont.h
#ifndef __STFONT_H__
#define __STFONT_H__

// Forward-declare libst types.
#include "stForward.h"
#include "STUtil.h"

#include <string>

/*
*  Forward-declare an "implementation" type that will hold the
*  implementation-dependent details for the STFont. This
*  insulates clients from the use of FreeType2 in the implementation.
*/
struct STFontImpl;

/**
* A font engine. An instance of STFont encapsulates a font face of a certain
* size.  This class, which wraps Freetype2 functionality, provides information
* about the face and manages the rendering of text strings to the screen using
* this font.  Rendering is performed via bitmap glyphs.  Users should pay
* attention to units when using STFont.
*/
class STFont
{
public:
    // Load a new font of a given size from a font file.
    STFont(const std::string& fontName, int fontSize);

    ~STFont();

    // Units of font size are points
    void  SetSize(int fontSize);
    int   GetSize() const;
    STStatus SetFace(const std::string& fontName, int fontSize);

    // Return width of rendered string in units of pixels
    float DrawString(const std::string& str, const STColor4f& color);
    float ComputeWidth(const std::string& str);

    // The following accessors return values in units of pixels
    // They are floating point values to provide subpixel precision
    float GetHeight() const;
    float GetAscender() const;
    float GetDescender() const;

private:
    int GetBitmapIndex(unsigned int character);
    int GenerateBitmap(unsigned int character);

    static const int kDefaultFontSize = 12;

    STFontImpl* mImpl;
};

#endif // __STFONT_H__
